import { NextRequest, NextResponse } from 'next/server'

export async function handleRedirect(request: NextRequest, response: NextResponse) {
  response.headers.set('x-pathname', request.nextUrl.pathname)
  // 获取当前路径
  const pathname = request.nextUrl.pathname

  // 如果是根路径，重定向到 /movie
  if (pathname === '/') {
    return NextResponse.redirect(new URL('/movie', request.url))
  }

  return response
}
